﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using jqGrid.Models.NorthWind;

namespace jqGrid.Repositories.NorthWind
{
    public class SuppliersRepository : ISuppliersRepository
    {
        #region Fields
        NorthWindDataContext _dataContext = new NorthWindDataContext();
        #endregion

        #region ISuppliersRepository Members
        public IQueryable<Supplier> GetSuppliers()
        {
            return _dataContext.Suppliers.OrderBy("CompanyName");
        }

        public Supplier GetSupplier(int supplierId)
        {
            return (from supplier in _dataContext.Suppliers
                    where supplier.SupplierID == supplierId
                    select supplier).First();
        }
        #endregion
    }
}